package tech.aistar.day08;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/3/17 9:12 上午
 */
public class StaticIdDemo {
    private int id = 10;

    //静态的属性 - 别名 - "类变量" -> 对象共享
    //静态的成员内存中的实例有且仅有1份.
    private static int sid = 100;

    public StaticIdDemo(){
        //this.id = id++;
        this.id = sid++;
    }

    public int getId() {
        return id;
    }

    public static void main(String[] args) {
        StaticIdDemo s1 = new StaticIdDemo();
        System.out.println(s1.getId());//100

        StaticIdDemo s2 = new StaticIdDemo();
        System.out.println(s2.getId());//101

        StaticIdDemo s3 = new StaticIdDemo();
        System.out.println(s3.getId());//102
    }
}
